/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.32                          *
*        Compiled Oct  8 2015, 11:59:02                              *
*        (c) 2015 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_WINDOW_0    (GUI_ID_USER + 0x07)
#define ID_TEXT_0    (GUI_ID_USER + 0x08)

#define TEXT_X_SIZE    200
#define TEXT_Y_SIZE    45

#define X_LCD_SIZE     800
#define Y_LCD_SIZE     480

#define TEXT_X_POS     ((X_LCD_SIZE-TEXT_X_SIZE)/2)
#define TEXT_Y_POS     ((Y_LCD_SIZE-TEXT_Y_SIZE)/2+150)


/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { WINDOW_CreateIndirect, "App_Startup", ID_WINDOW_0, 0, 0, X_LCD_SIZE, Y_LCD_SIZE, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "", ID_TEXT_0, TEXT_X_POS, TEXT_Y_POS, TEXT_X_SIZE, TEXT_Y_SIZE, 0, 0x64, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/


extern GUI_CONST_STORAGE GUI_BITMAP bmAllOptomedic;
extern GUI_CONST_STORAGE GUI_BITMAP bmbackLogoWord;
extern GUI_CONST_STORAGE GUI_BITMAP bmbackLogoColorCircle24;
extern GUI_CONST_STORAGE GUI_BITMAP bmcolortOptomedicLogo;
extern GUI_CONST_STORAGE GUI_BITMAP bmoptomedicbig;








#define DOT_ARR_SIZE  10
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  WM_HWIN hWin;
  WM_HTIMER hTimer;

  static char dots[DOT_ARR_SIZE] = {0};
  GUI_RECT Rect; 
  static char dotIndex = 0;
	
  hWin = pMsg->hWin;
  switch (pMsg->MsgId) 
  {
  case WM_INIT_DIALOG:
	WM_GetClientRect(&Rect);

    hItem = pMsg->hWin;
    WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
     hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "");
    TEXT_SetFont(hItem, GUI_FONT_32B_ASCII);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00F6F6F6));
	
	hTimer = WM_CreateTimer(hWin, 0, 500, 0);
    break;
	case WM_PAINT:
		WM_GetClientRect(&Rect); 
		GUI_DrawBitmap(&bmbackLogoColorCircle24, (Rect.x1-Rect.x0-399)/2-90, (Rect.y1-Rect.y0-170)/2-30);   
		GUI_DrawBitmap(&bmbackLogoWord, (Rect.x1-Rect.x0-399)/2+20, (Rect.y1-Rect.y0-170)/2);   
		GUI_SetBkColor(GUI_WHITE);
	break;
	 case WM_TIMER:
		 hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);

		 if (dotIndex >= DOT_ARR_SIZE)
		 {
			 dotIndex = 0;
			 memset(dots, 0, sizeof(dots));
		 }
		 dots[dotIndex++] = '.';

		 TEXT_SetText(hItem, dots);
		
		 WM_RestartTimer(pMsg->Data.v, 500);
		 break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateApp_Startup
*/

WM_HWIN CreateApp_Startup(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  return hWin;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/
